package com.gitee.huanminabc.db_freedom.segments;

import com.gitee.huanminabc.db_freedom.base.SqlFun;

public interface SqlFunSegments<Children, T, R>  extends SqlRelationSegments<Children, T, R> {
    //sum
    Children SUM(String sql);

    Children SUM(String sql, String alias);

    <Y> Children SUM(SqlFun<Y, ?> column);

    Children SUM_REDUCE(SqlFun<Children, Children> sql);

    <Y> Children SUM_REDUCE(SqlFun<Children, Children> sql, SqlFun<Y, ?> alias);

    //avg
    Children AVG(String sql);

    Children AVG(String sql, String alias);

    <Y> Children AVG(SqlFun<Y, ?> column);

    Children AVG_REDUCE(SqlFun<Children, Children> sql);

    Children AVG_REDUCE(SqlFun<Children, Children> sql, String alias);

    //max
    Children MAX(String sql);

    Children MAX(String sql, String alias);

    <Y> Children MAX(SqlFun<Y, ?> column);

    Children MAX_REDUCE(SqlFun<Children, Children> sql);

    Children MAX_REDUCE(SqlFun<Children, Children> sql, String alias);


    //min
    Children MIN(String sql);

    Children MIN(String sql, String alias);

    <Y> Children MIN(SqlFun<Y, ?> column);

    Children MIN_REDUCE(SqlFun<Children, Children> sql);

    Children MIN_REDUCE(SqlFun<Children, Children> sql, String alias);


    //count
    Children COUNT(String sql);

    Children COUNT(String sql, String alias);

    <Y> Children COUNT(SqlFun<Y, ?> column);

    Children COUNT_REDUCE(SqlFun<Children, Children> sql);

    Children COUNT_REDUCE(SqlFun<Children, Children> sql, String alias);


    <Y> Children IFNULL(SqlFun<Y, ?> column, Object defaultValue);

    <Y> Children IFNULL(SqlFun<Y, ?> column1, SqlFun<Y, ?> column2, String alias);


    <Y>  Children  SUBSTR( SqlFun<Y, ?> column,int pos,int len);

    <Y> Children CONCAT( String alias,SqlFun<Y, ?>... column);

    Children CONCAT( String alias,String... column);

    <Y>  Children LENGTH( SqlFun<Y, ?> column,String alias);

    Children LENGTH( String column,String alias);
}
